//引入
const mongoose = require('mongoose');

//安装 mongoose
module.exports = function(success, error){
    //连接                                 数据库
    mongoose.connect('mongodb://127.0.0.1:27017/h50415', { useNewUrlParser: true,useUnifiedTopology: true } );
    //设置回调
    mongoose.connection.on('open', () => {
        //执行成功的回调
        success();
    });

    mongoose.connection.on('error', () => {
        //执行失败的回调
        error();
    });
}

